<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script>
        var num = [98, 31, 5, 27, 2, 78];
        console.log(num);
                for(var j = 0; j<num.length-1;j++){
                    for(var i = 0; i<num.length-1-j;i++){
                        if(num[i]>num[i+1]){
                            var temp = num[i];
                            num[i]=num[i+1];
                            num[i+1]=temp;
                        }
                    }
                } 
        console.log(num);
    </script>
</body>
</html>